import { AxiosError } from "axios";
import { getUserInfo, signUp } from "./mohe/user";
import { draw } from "./mohe/draw";
import { sendMail } from "./mail/mail";
import { formatError } from "./utils/format";

try {
  let userInfo = await getUserInfo();
  console.log(`当前魔豆数量: ${userInfo.modou}`);

  let sign = await signUp();
  console.log(`签到获得魔豆: ${sign.modou}-${userInfo.modou}`);

  let drawRes1 = await draw();
  console.log(`抽奖1: ${drawRes1.winning_desc}`);
  let drawRes2 = await draw();
  console.log(`抽奖2: ${drawRes2.winning_desc}`);
} catch (e) {
  let msg = formatError(e as AxiosError);
  sendMail("魔盒签到异常", msg);
  console.log(msg);
}
